// Test des blocs

/*
#include "Utils\\AWindow.h"
#include "Bloc.h"
#include "Sprite.h"
#include "Sprites.h"
#include <SDL/SDL_image.h>
#include <vector>
#include "BlocManager.h"

using namespace SDL::UTILS;

class Window : public AWindow
{
private:
	SDL_Event m_event;
	bool m_quit;
	BlocManager m_blocManager;

public:
	Window() : AWindow(), m_quit(false)
	{
		Sint16 x = 0, y = 0;

		for (int j = 0; j < 35; j++)
		{
			for (int i = 0; i < 25; i++, x += 32)
				m_blocManager.Add("normal", Rect(x, y));
			y += 16;
			x = 0;
		}
	}

	virtual ~Window()
	{
	}

	void CheckBlocClicked()
	{
		int x = 0, y = 0;
		SDL_GetMouseState(&x, &y);
		std::vector<Bloc*> blocs;
		m_blocManager.GetAllBlocs(blocs);
		for (int i = 0; i < blocs.size(); i++)
		{
			if (blocs[i]->GetPosition().IsInArea(Rect(x, y, 0, 0),
					Rect(blocs[i]->GetPosition().x, blocs[i]->GetPosition().y,
					blocs[i]->GetCurrentSprite()->CurrentFrame.GetW(),
					blocs[i]->GetCurrentSprite()->CurrentFrame.GetH())))
			{
				blocs[i]->SetLife(0);
			}
		}
	}

	void DrawBlocs()
	{
		m_blocManager.Draw(m_screen);
		std::vector<Bloc*> blocs;
		m_blocManager.GetAllBlocs(blocs);
		for (int i = 0; i < blocs.size(); i++)
		{
			if (blocs[i]->GetLife() == 0)
			{
				if (blocs[i]->GetCurrentSprite()->Name == "blocnormal")
				{
					blocs[i]->SetCurrentSprite(*m_blocManager.GetSprites().Find("blocdeath"));
					blocs[i]->Move(-16, -16);
				}
				else
				{
					if (blocs[i]->GetCurrentSprite()->Finish())
					{
						blocs[i]->SetCurrentSprite(*m_blocManager.GetSprites().Find("blocnormal"));
						blocs[i]->Move(16, 16);
						blocs[i]->SetLife(100);
					}
				}
			}
		}
	}

	virtual int Exec()
	{
		int tempsA = 0, tempsB = 0, temps = 10;

		while (!m_quit)
		{
			tempsA = SDL_GetTicks();
			if (tempsA - tempsB > temps)
			{
				while (SDL_PollEvent(&m_event))
				{
					switch (m_event.type)
					{
					case SDL_QUIT:
						m_quit = true;
						break ;

					case SDL_KEYDOWN:
						switch (m_event.key.keysym.sym)
						{
						default: break ;
						}
						break ;

					case SDL_MOUSEBUTTONDOWN:
						//this->CheckBlocClicked();
						break ;
					}
				}
				
				this->CheckBlocClicked();
				SDL_FillRect(m_screen, NULL, 0x00FFFF);
				this->DrawBlocs();

				SDL_Flip(m_screen);
				tempsB = tempsA;
			}
			else
				SDL_Delay(temps - (tempsA - tempsB));
		}

		return (EXIT_SUCCESS);
	}
};
*/

#include "config.h"
#ifdef _DEBUG
# pragma comment(lib, "..\\..\\lib\\Debug\\Utils-d.lib")
# pragma comment(lib, "..\\..\\lib\\Debug\\Elements-d.lib")
# pragma comment(lib, "..\\..\\Projects\\Debug\\BreakerElements-d.lib")
#else
# pragma comment(lib, "..\\..\\lib\\Release\\Utils.lib")
# pragma comment(lib, "..\\..\\lib\\Release\\Elements.lib")
# pragma comment(lib, "..\\..\\Projects\\Release\\BreakerElements.lib")
#endif // _DEBUG

#include <iostream>
#include "Window.h"

using namespace SDL::UTILS;

int main(int, char**)
{
	Uint32 sdlflags = SDL_INIT_VIDEO;
	Uint32 videoflags = SDL_HWSURFACE | SDL_DOUBLEBUF;
	SDLConfig config(sdlflags, 1024, 768, videoflags,
					"WatashiTachiNoSekai: Casse Briques Editor");

	AWindow::InitLibs(config);
	Window w;

	w.Init(config);
	return (w.Exec());
}
